﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProductTypeViewer.ascx.cs" Inherits="admin_webparts_Plug_ins_Product_ProductTypeViewer" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<%@ Import Namespace="NTTHAO.Web.BL.Product" %>
<style type="text/css">
    #spLinkAdd, #spLinkEdit, #spLinkDelete, #spLinkAddContent, #spLinkView, #spLinkAddPro, #spTypeManage, #spConfig {font-size:1.1em; font-weight: bold; }
    #spLinkAdd button, #spLinkEdit button, #spLinkDelete button, #spLinkAddContent button, #spLinkView button, #spLinkAddPro button, #spTypeManage button, #spConfig button { font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; }
</style>
<div class="tip" style="min-height: 22px; overflow: hidden;">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td align="left">
                <h2 style="padding-top: 2px;"><%=(this._Type == null ? LanguageUtility.GetLanguageText("PRODUCT_GROUP", Session) : this._Type.Name)%></h2>
            </td>
            <td align="right" style="white-space: nowrap;">
                <div style="text-align: right;">
                <% if (this._Type == null && this._IsAdminLogged) { %>
                    <span id="spConfig" class="yui-button yui-link-button yuibtn yuibtn-icon btnconfig"><span class="first-child"><a href="?action=config&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>"><%=LanguageUtility.GetLanguageText("SET_DEFAULT_PRO_CONFIG", Session)%></a></span></span>
                <%} %>
                <%if (this._Type != null){ %>
                    <span id="spLinkView" class="yui-button yui-link-button expand"><span class="first-child"><a href="javascript: return false;" onclick="javascript: showHideDetail(this); return false;"><%=LanguageUtility.GetLanguageText("DETAIL", Session)%></a></span></span>
                <%} %>
                    <span id="spTypeManage" class="yui-button yui-link-button yuibtn yuibtn-icon btnmanage"><span class="first-child"><a href="?action=mantype&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>"><%=LanguageUtility.GetLanguageText("MANAGE_SUB_PRO_TYPE", Session)%></a></span></span>
                <%if (this._Type != null) { %>
                    <span id="spLinkEdit" class="yui-button yui-link-button yuibtn yuibtn-icon btnedit"><span class="first-child"><a href="?action=edittype&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>"><%=LanguageUtility.GetLanguageText("EDIT", Session)%></a></span></span>
                    <span id="spLinkDelete" class="yui-button yui-link-button yuibtn yuibtn-icon btndelete"><span class="first-child"><a href="?action=deletetype&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>" onclick="javascript: return confirmDelete();"><%=LanguageUtility.GetLanguageText("DELETE", Session)%></a></span></span>
                <%}%>
                <%if (this._Type != null){ %>
                    <span id="spMoveTo" class="yui-button yui-link-button yuibtn yuibtn-icon btnmove"><span class="first-child"><a href="?action=movetype&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>"><%=LanguageUtility.GetLanguageText("MOVE", Session)%></a></span></span>
                <%} %>
                </div>
                <div style="text-align: right; margin-top: 5px;">
                    <span id="spLinkAdd" class="yui-button yui-link-button yuibtn yuibtn-icon btnaddf"><span class="first-child"><a href="?action=addtype&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>"><%=LanguageUtility.GetLanguageText("ADD_SUB_PRO_TYPE", Session)%></a></span></span>
                <%if (this._Type != null) { %>
                    <span id="spLinkAddPro" class="yui-button yui-link-button yuibtn yuibtn-icon btnaddp"><span class="first-child"><a href="?action=proadd&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>"><%=LanguageUtility.GetLanguageText("ADD_PRODUCT", Session)%></a></span></span>
                <%} %>
                <%if (this._Type != null){ %>
                    <span id="spCopyPro" class="yui-button yui-link-button yuibtn yuibtn-icon btnmove"><span class="first-child"><a href="?action=procopy&g=<%=this.Request.QueryString["g"] %>&typeid=<%=this.Request.QueryString["typeid"] %>"><%=LanguageUtility.GetLanguageText("MOVE", Session)%>/<%=LanguageUtility.GetLanguageText("COPY", Session)%> <%=LanguageUtility.GetLanguageText("PRODUCT", Session).ToLower()%></a></span></span>
                <%} %>
                </div>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        YAHOO.util.Event.onDOMReady(function () {
            var spTypeManage = new YAHOO.widget.Button("spTypeManage");
            var spLinkAdd = new YAHOO.widget.Button("spLinkAdd");
            var spLinkAddPro = new YAHOO.widget.Button("spLinkAddPro");
            var spLinkView = new YAHOO.widget.Button("spLinkView");
            var spLinkEdit = new YAHOO.widget.Button("spLinkEdit");
            var spLinkDelete = new YAHOO.widget.Button("spLinkDelete");
            var spConfig = new YAHOO.widget.Button("spConfig");
            var spMoveTo = new YAHOO.widget.Button("spMoveTo");
            var spCopyPro = new YAHOO.widget.Button("spCopyPro");
        });
    </script>
</div>
<script type="text/javascript">
    function confirmDelete() {
        var str = "";
        str.replaceAll
        return confirm('<%=LanguageUtility.GetLanguageText("CONFIRM_DELETE", Session).Replace("'", "''")%>'.replace('<br />', '\n'));
    }
    
    function showHideDetail(o) {
        if (YAHOO.util.Dom.getStyle('tbTypeDetail', 'display') == 'table') {
            YAHOO.util.Dom.setStyle('tbTypeDetail', 'display', 'none'); 
            o.innerText = '<%=LanguageUtility.GetLanguageText("DETAIL", Session)%>';
            YAHOO.util.Dom.removeClass(o.parentNode.parentNode, 'collapse');
            YAHOO.util.Dom.addClass(o.parentNode.parentNode, 'expand');
        } else {
            YAHOO.util.Dom.setStyle('tbTypeDetail', 'display', 'table'); 
            o.innerText = '<%=LanguageUtility.GetLanguageText("HIDE_DETAIL", Session)%>';
            YAHOO.util.Dom.removeClass(o.parentNode.parentNode, 'expand');
            YAHOO.util.Dom.addClass(o.parentNode.parentNode, 'collapse');
        }
        if (typeof onWindowResize == 'function') {
            onWindowResize();
        }
    }
</script>
<%if (this._Type != null)
  { %>
<table id="tbTypeDetail" class="grid" border="1" cellspacing="0" cellpadding="3" style="display: none; margin-bottom: 10px;">
    <tr class="odd">
        <td width="200" align="right"><%=LanguageUtility.GetLanguageText("NAME", Session) %>:</td>
        <td><%=this._Type.Name%></td>
    </tr>
    <tr class="even">
        <td align="right"><%=LanguageUtility.GetLanguageText("DESCRIPTION", Session) %>:</td>
        <td><%=this._Type.Description %></td>
    </tr>
    <tr class="odd">
        <td align="right"><%=LanguageUtility.GetLanguageText("REPRESENTATIVE_IMAGE", Session)%>:</td>
        <td><%=this._Type.RepresentativeImage == "" ? ("(" + LanguageUtility.GetLanguageText("NONE", Session) + ")") : ("<img src=\"../" + Constant.UPLOAD_FILE_PATH + "product/type/" + this._Type.ID.ToString() + "/" + this._Type.RepresentativeImage + "\" style=\"max-width: 200px; max-height: 150px;\"/>")%></td>
    </tr>
    <tr class="even">
        <td align="right"><%=LanguageUtility.GetLanguageText("ACTIVE", Session)%>:</td>
        <td><%=(this._Type.Actived ? "<img src=\"resources/images/active.png\" />" : "<img src=\"resources/images/inactive.png\" />") %> </td>
    </tr>
</table>

<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-bottom: 10px;">
    <tr>
        <td nowrap="nowrap" align="left" style="width: 120px;"><%=LanguageUtility.GetLanguageText("TOTAL", Session)%>:&nbsp;<%=this._Products == null ? 0 : this._Products.Rows.Count%>/<%=this._TotalItem %>&nbsp;</td>
        <td nowrap="nowrap" style="width: 1px;"><span><%=LanguageUtility.GetLanguageText("PAGE", Session)%>:&nbsp;</span></td>
        <td align="right">
            <div class="pagenum">
                <ul>
                    <%if (this._PageNo > 1) { %><li><a href="ProductContent.aspx?action=view&g=<%=this._Type.GroupID %>&typeid=<%=this._Type.ID %>&p=<%=this._PageNo - 1 %>"><</a></li>
                    <%} else { %><li><a><</a></li><%} %>
					<%for (int i = 1; i <= this._PageCount; i++) { %>
                    <li class="<%= this._PageNo == i ? "selected" : "" %>"><a href="ProductContent.aspx?action=view&g=<%=this._Type.GroupID %>&typeid=<%=this._Type.ID %>&p=<%=i %>"><%=i %></a></li>
                    <%} %>
					<%if (this._PageNo < this._PageCount) { %><li><a href="ProductContent.aspx?action=view&g=<%=this._Type.GroupID %>&typeid=<%=this._Type.ID %>&p=<%=this._PageNo + 1 %>">></a></li>
                    <%} else { %><li><a>></a></li><%} %>
				</ul>
            </div>
        </td>
    </tr>
</table>
<table id="tbGrid" class="grid" border="1" cellpadding="0" cellspacing="0">
    <tr>
        <th width="42px">#</th>
        <th><%=LanguageUtility.GetLanguageText("PRODUCT_ID", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("NAME", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("PRESENTATIVE_IMAGE", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("PRICE", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("ACTIVE", Session)%></th>
        <th class="fw"><%=LanguageUtility.GetLanguageText("FUNCTIONS", Session)%></th>
    </tr><% 
      
        int groupID = this._Type.GroupID;
        int typeID = this._Type.ID;
        if (this._Products != null) for (int i = 0; i < this._Products.Rows.Count; i++)
        {
            System.Data.DataRow row = this._Products.Rows[i];
            int id = (int)row[Product.ID__COLUMN_NAME];
            string proID = row[Product.PRODUCTID__COLUMN_NAME].ToString();
            string name = row[Product.PRODUCTNAME__COLUMN_NAME].ToString();
            string imagePath = row[Product.IMAGEPATH__COLUMN_NAME].ToString();
            string image = row[Product.IMAGE__COLUMN_NAME].ToString();
            float price = (float)row[Product.PRICE__COLUMN_NAME];
            int currency = (int)row[Product.CURRENCY__COLUMN_NAME];
            bool actived = (bool)row[Product.ACTIVED__COLUMN_NAME];
        %>
    <tr class="<%=(i%2==1?"even":"odd") %>">
        <td align="center"><%=(this._PageNo - 1) * PAGE_SIZE + i + 1 %></td>
        <td><%=proID %></td>
        <td><%=name %></td>
        <td align="center"><img class="mw100 mh100" alt="" src="<%=this._ProductUploadeFolder %><%=imagePath + image %>" /></td>
        <td align="right"><b><%=price.ToString("###,##0.0") %></b>&nbsp;<%=_Currency.ContainsKey(currency) ? _Currency[currency] : "-" %></td>
        <td align="center"><%=(actived ? "<img src=\"resources/images/active.png\" />" : "<img src=\"resources/images/inactive.png\" />")%></td>
        <td align="center">
            <ul class="icon" style="width: 64px;">
                <li><a title="<%=LanguageUtility.GetLanguageText("EDIT", Session)%>" href="ProductContent.aspx?action=proedit&g=<%=this._Type.GroupID %>&typeid=<%=this._Type.ID %>&id=<%=id %>" class="icon editbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("DELETE", Session)%>" href="ProductContent.aspx?action=prodel&g=<%=this._Type.GroupID %>&typeid=<%=this._Type.ID %>&id=<%=id %>" class="icon deletebn" onclick="javascript: return confirm('<%=LanguageUtility.GetLanguageText("CONFIRM_DELETE", Session).Replace("<br />", "\\n")%>');">&nbsp</a></li>
<!--
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE_UP", Session)%>" href="ProductContent.aspx?action=promoveup&g=<%=this._Type.GroupID %>&typeid=<%=this._Type.ID %>&id=<%=id %>" class="icon ascbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE_DOWN", Session)%>" href="ProductContent.aspx?action=promovedown&g=<%=this._Type.GroupID %>&typeid=<%=this._Type.ID %>&id=<%=id %>" class="icon descbn">&nbsp</a></li>
-->
            </ul>
        </td>
    </tr>
    <%} %>
</table>

<%} %>
